package com.navinfo.tripanalysis.offline.service.impl.huashen;

import com.navinfo.location.mileage.bean.MileageAndFuel;
import com.navinfo.location.mileage.bean.Point;
import com.navinfo.location.mileage.calculation.Calculation;
import com.navinfo.tripanalysis.common.pojo.Point0200;
import com.navinfo.tripanalysis.common.pojo.RunningType;
import com.navinfo.tripanalysis.common.pojo.RunningTypeEnum;
import com.navinfo.tripanalysis.offline.service.MilAndFuelService;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 一汽精准里程油耗算法
 */
@RunningType(value = RunningTypeEnum.HS, interfaceClass =MilAndFuelService.class )
public class MilAndFuelServiceImpl implements MilAndFuelService {
    @Override
    public MileageAndFuel calcMileageFuel(List<Point0200> points) {
        List<Point> points1 = points.stream().map(point -> {
            Point p = new Point();
            p.setTid(point.getTid());
            p.setGpsDate(point.getGpsTime());
            p.setGpsMileage(point.getGpsMileage());
            p.setDiffMileage(point.getIntegralMileage());
            p.setEcuMileage(point.getEcuMileage());
            p.setMeterMileage(point.getMeterMileage());
            p.setRotation(point.getRotation());
            p.setTotalFuelCons(point.getTotalFuelCons());
            p.setSerialNumber(point.getSerialNumber());
            return p;
        }).collect(Collectors.toList());
        return Calculation.getStdMilAndFuel(points1);
    }
}
